package com.yy.train.ticket.train.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yy.train.ticket.into.page.LinePage;
import com.yy.train.ticket.train.entity.TtLineEntity;
import com.yy.train.ticket.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yy.train.ticket.train.entity.TtTrainSeatEntity;
import com.yy.train.ticket.train.service.TtTrainSeatService;





/**
 * 座位
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-09-25 10:38:44
 */
@RestController
@RequestMapping("tt/seat")
public class TtTrainSeatController {
    @Autowired
    private TtTrainSeatService ttTrainSeatService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Long trainId){
        return this.ttTrainSeatService.trainSeatlist(trainId);

      //  return R.ok(this.ttTrainSeatService.list(Wrappers.<TtTrainSeatEntity>lambdaQuery().eq(StringUtils.checkValNotNull(trainId),TtTrainSeatEntity::getTrainId,trainId)));

    }
    @PostMapping("/page")
    public R page(@RequestBody LinePage trainPage){
     /*   LambdaQueryWrapper<TtTrainSeatEntity> lambdaQueryWrapper = Wrappers.lambdaQuery();
        Page<TtTrainSeatEntity> pages = new Page<TtTrainSeatEntity>(trainPage.getPageNum(), trainPage.getPageSize());
        IPage<TtTrainSeatEntity> iPage = ttTrainSeatService.page(pages, lambdaQueryWrapper);
        return R.ok(iPage);*/
        return this.ttTrainSeatService.trainSeatPage(trainPage);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{seatId}")
    public R info(@PathVariable("seatId") Integer seatId){
		TtTrainSeatEntity ttTrainSeat = ttTrainSeatService.getById(seatId);

        return R.ok(ttTrainSeat);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody TtTrainSeatEntity ttTrainSeat){
		ttTrainSeatService.save(ttTrainSeat);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody TtTrainSeatEntity ttTrainSeat){
		ttTrainSeatService.updateById(ttTrainSeat);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody List<Integer> seatIds){
		ttTrainSeatService.removeByIds(seatIds);

        return R.ok();
    }

}
